package com.tbi.algorithm;

import java.util.List;

public abstract class AbstractGenethicAlgorithm {
	
	public void doIt(Object obj){
		int generation = 0;
		
		List<Object> population = createInitialPopulation(obj);
		
		evaluate(population);
		while(!stopCondition(population, generation)){
			selection(population);
			crossover(population);
			mutation(population);
			evaluate(population);
			generation++;
		}
	}

	protected abstract List<Object> createInitialPopulation(Object obj);
	protected abstract void evaluate(List<Object> population);
	protected abstract void selection(List<Object> population);
	protected abstract void crossover(List<Object> population);
	protected abstract void mutation(List<Object> population);
	protected abstract boolean stopCondition(List<Object> population, int generation);
}
